import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import {Storage} from '@ionic/storage';
import {BookPage} from "../book/book";
/*
  Generated class for the Favour page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
  selector: 'page-favour',
  templateUrl: 'favour.html'
})
export class FavourPage {
  items: Array<{title: string, note: string, logo: string, url: string}>;

  constructor(public navCtrl: NavController, public navParams: NavParams, public storage:Storage) {
    this.storage.ready().then(() => {

      storage.get('favour').then((val) => {
        let history;
        if (val == null) {
          history = [];
        } else {
          history = val;
        }
        this.items = history;
      })
    });
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad FavourPage');
  }

  itemTapped(event, item) {
    this.navCtrl.push(BookPage, {
      item: item
    });
  }
}
